﻿//获取浏览器参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

$(function () {
    var t = getQueryString("t");
    $('#phone').focus();  //当前页面输入框选中

    $(document).on('keydown', function (e) {
        switch (e.keyCode) {
            case 27:   //Esc操作
                e.preventDefault();
                if (t == 1) {
                    var index = parent.parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.parent.layer.close(index);
                    parent.$('#sku').focus();
                }
                else {
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                    parent.window.location.reload();
                }
                break;
            case 13:    //回车
                e.preventDefault();
                var phone = $('#phone').val();      //手机号码
                var code = $('#code').val();        //验证码
                var name = $('#name').val();        //姓名
                newmember(phone, code, name, "");
                break;
        }
    })
});